how to use aws gp2 storageclass

  1. get sc

    kubectl get sc
    gp2             kubernetes.io/aws-ebs   Delete          WaitForFirstConsumer   false                  1d
    
  2. create pvc

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: test
    spec:
      accessModes:
        - ReadWriteOnce
      storageClassName: gp2
      resources:
        requests:
          storage: 1Gi
    
  3. create pod

    apiVersion: v1
    kind: Pod
    metadata:
      name: test
    spec:
      containers:
      - name: test
        image: centos
        command: ["/bin/sh"]
        args: ["-c", "sleep 86400"]
        volumeMounts:
        - name: test
          mountPath: /test
      volumes:
      - name: persistent-storage
        persistentVolumeClaim:
          claimName: test
    
  4. get ebs

    aws ec2 describe-volumes --filters Name=tag:Name,Values=kubernetes-dynamic-pvc-9ce22b51-55ab-49aa-92a6-85101bc0a820
    

references: